package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.NoticeDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.Notice;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface NoticeMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    BasicColumn[] selectList = BasicColumn.columnList(noticeId, noticeTitle, noticeType, noticeContent, status, createBy, createTime, updateBy, updateTime, remark);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<Notice> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("NoticeResult")
    Optional<Notice> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="NoticeResult", value = {
        @Result(column="notice_id", property="noticeId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="notice_title", property="noticeTitle", jdbcType=JdbcType.VARCHAR),
        @Result(column="notice_type", property="noticeType", jdbcType=JdbcType.CHAR),
        @Result(column="notice_content", property="noticeContent", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.CHAR),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<Notice> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, notice, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, notice, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    default int deleteByPrimaryKey(Integer noticeId_) {
        return delete(c -> 
            c.where(noticeId, isEqualTo(noticeId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.608+08:00", comments="Source Table: sys_notice")
    default int insert(Notice record) {
        return MyBatis3Utils.insert(this::insert, record, notice, c ->
            c.map(noticeId).toProperty("noticeId")
            .map(noticeTitle).toProperty("noticeTitle")
            .map(noticeType).toProperty("noticeType")
            .map(noticeContent).toProperty("noticeContent")
            .map(status).toProperty("status")
            .map(createBy).toProperty("createBy")
            .map(createTime).toProperty("createTime")
            .map(updateBy).toProperty("updateBy")
            .map(updateTime).toProperty("updateTime")
            .map(remark).toProperty("remark")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default int insertSelective(Notice record) {
        return MyBatis3Utils.insert(this::insert, record, notice, c ->
            c.map(noticeId).toPropertyWhenPresent("noticeId", record::getNoticeId)
            .map(noticeTitle).toPropertyWhenPresent("noticeTitle", record::getNoticeTitle)
            .map(noticeType).toPropertyWhenPresent("noticeType", record::getNoticeType)
            .map(noticeContent).toPropertyWhenPresent("noticeContent", record::getNoticeContent)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default Optional<Notice> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, notice, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default List<Notice> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, notice, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default List<Notice> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, notice, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default Optional<Notice> selectByPrimaryKey(Integer noticeId_) {
        return selectOne(c ->
            c.where(noticeId, isEqualTo(noticeId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, notice, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    static UpdateDSL<UpdateModel> updateAllColumns(Notice record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(noticeId).equalTo(record::getNoticeId)
                .set(noticeTitle).equalTo(record::getNoticeTitle)
                .set(noticeType).equalTo(record::getNoticeType)
                .set(noticeContent).equalTo(record::getNoticeContent)
                .set(status).equalTo(record::getStatus)
                .set(createBy).equalTo(record::getCreateBy)
                .set(createTime).equalTo(record::getCreateTime)
                .set(updateBy).equalTo(record::getUpdateBy)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(remark).equalTo(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Notice record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(noticeId).equalToWhenPresent(record::getNoticeId)
                .set(noticeTitle).equalToWhenPresent(record::getNoticeTitle)
                .set(noticeType).equalToWhenPresent(record::getNoticeType)
                .set(noticeContent).equalToWhenPresent(record::getNoticeContent)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime)
                .set(remark).equalToWhenPresent(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default int updateByPrimaryKey(Notice record) {
        return update(c ->
            c.set(noticeTitle).equalTo(record::getNoticeTitle)
            .set(noticeType).equalTo(record::getNoticeType)
            .set(noticeContent).equalTo(record::getNoticeContent)
            .set(status).equalTo(record::getStatus)
            .set(createBy).equalTo(record::getCreateBy)
            .set(createTime).equalTo(record::getCreateTime)
            .set(updateBy).equalTo(record::getUpdateBy)
            .set(updateTime).equalTo(record::getUpdateTime)
            .set(remark).equalTo(record::getRemark)
            .where(noticeId, isEqualTo(record::getNoticeId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.609+08:00", comments="Source Table: sys_notice")
    default int updateByPrimaryKeySelective(Notice record) {
        return update(c ->
            c.set(noticeTitle).equalToWhenPresent(record::getNoticeTitle)
            .set(noticeType).equalToWhenPresent(record::getNoticeType)
            .set(noticeContent).equalToWhenPresent(record::getNoticeContent)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(createBy).equalToWhenPresent(record::getCreateBy)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(updateBy).equalToWhenPresent(record::getUpdateBy)
            .set(updateTime).equalToWhenPresent(record::getUpdateTime)
            .set(remark).equalToWhenPresent(record::getRemark)
            .where(noticeId, isEqualTo(record::getNoticeId))
        );
    }
}